# import requests
# url = 'http://www.bilibili.com'
# head = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36'}
# response = requests.get(url=url,headers=head)
# response.encoding = response.apparent_encoding
# neir = response.text
# print(neir)


# import requests
# import json
# url = 'https://fanyi.baidu.com/sug'
# head = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36'}
# a = input('请输入一个单词：')
# data = {'kw':a}
# r = requests.post(url=url,data=data,headers=head)
# neir = r.text
# print(json.loads(neir))

import requests
def get_html(url,time=10):
    head = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36'}
    try:
        r = requests.get(url,headers=head,timeout=time)
        r.encoding = r.apparent_encoding
        r.raise_for_status()
        return r.text
    except Exception as error:
        print(error)
if __name__ == '__main__':
    url='http://www.bilibili.com'
    print(get_html(url))